---
title: "VAMP SIMD Performance Architecture - Memory Layout & Vectorization"
---
graph TB
    %% Traditional vs VAMP Comparison
    subgraph "Traditional Sequential Collision Detection"
        T1["Config 1"] --> TC1["Check 1"]
        T2["Config 2"] --> TC2["Check 2"] 
        T3["Config 3"] --> TC3["Check 3"]
        T4["Config 4"] --> TC4["Check 4"]
        TC1 --> TR1["Result 1"]
        TC2 --> TR2["Result 2"]
        TC3 --> TR3["Result 3"]
        TC4 --> TR4["Result 4"]
    end
    
    subgraph "VAMP Vectorized Collision Detection"
        V1["Config 1"] --> VL1[Lane 0]
        V2["Config 2"] --> VL2[Lane 1]
        V3["Config 3"] --> VL3[Lane 2]
        V4["Config 4"] --> VL4[Lane 3]
        V5["Config 5"] --> VL5[Lane 4]
        V6["Config 6"] --> VL6[Lane 5]
        V7["Config 7"] --> VL7[Lane 6]
        V8["Config 8"] --> VL8[Lane 7]
        
        VL1 --> SIMD["SIMD Instruction<br/>(8x parallel)"]
        VL2 --> SIMD
        VL3 --> SIMD
        VL4 --> SIMD
        VL5 --> SIMD
        VL6 --> SIMD
        VL7 --> SIMD
        VL8 --> SIMD
        
        SIMD --> VR["8 Results<br/>(single instruction)"]
    end
    
    %% Memory Layout Transformation
    subgraph "Memory Layout Optimization"
        %% AOS Layout
        AOS_START["OMPL Array-of-Structures (AOS)"]
        AOS_START --> AOS_MEM["Memory Layout:<br/>[j0,j1,j2,j3,j4,j5,j6] config1<br/>[j0,j1,j2,j3,j4,j5,j6] config2<br/>...<br/>(cache-inefficient for SIMD)"]
        
        %% Conversion Process
        AOS_MEM --> CONV["ompl_to_vamp()<br/>Zero-copy conversion<br/>Function-local static buffers"]
        
        %% SOA Layout
        CONV --> SOA_MEM["VAMP Structure-of-Arrays (SOA):<br/>[j0_c1,j0_c2,...,j0_c8] joint0<br/>[j1_c1,j1_c2,...,j1_c8] joint1<br/>...<br/>[j6_c1,j6_c2,...,j6_c8] joint6<br/>(SIMD-optimized)"]
        
        SOA_MEM --> SIMD_OPS["SIMD Operations<br/>Process all 8 configs<br/>simultaneously"]
    end
    
    %% Motion Validation Detail
    subgraph "Rake Motion Validation Strategy"
        MOTION_START["Motion Edge<br/>(start → goal)"]
        MOTION_START --> RAKE_SAMPLE["Rake Sampling<br/>t = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]"]
        
        RAKE_SAMPLE --> INTERP1["Interpolate config at t=0.1"] --> LANE1[SIMD Lane 0]
        RAKE_SAMPLE --> INTERP2["Interpolate config at t=0.2"] --> LANE2[SIMD Lane 1]
        RAKE_SAMPLE --> INTERP3["Interpolate config at t=0.3"] --> LANE3[SIMD Lane 2]
        RAKE_SAMPLE --> INTERP4["Interpolate config at t=0.4"] --> LANE4[SIMD Lane 3]
        RAKE_SAMPLE --> INTERP5["Interpolate config at t=0.5"] --> LANE5[SIMD Lane 4]
        RAKE_SAMPLE --> INTERP6["Interpolate config at t=0.6"] --> LANE6[SIMD Lane 5]
        RAKE_SAMPLE --> INTERP7["Interpolate config at t=0.7"] --> LANE7[SIMD Lane 6]
        RAKE_SAMPLE --> INTERP8["Interpolate config at t=0.8"] --> LANE8[SIMD Lane 7]
        
        LANE1 --> PARALLEL_CHECK["Parallel Collision Check<br/>(8 temporal samples)"]
        LANE2 --> PARALLEL_CHECK
        LANE3 --> PARALLEL_CHECK
        LANE4 --> PARALLEL_CHECK
        LANE5 --> PARALLEL_CHECK
        LANE6 --> PARALLEL_CHECK
        LANE7 --> PARALLEL_CHECK
        LANE8 --> PARALLEL_CHECK
        
        PARALLEL_CHECK --> MOTION_RESULT["Motion Valid<br/>(all samples clear)"]
    end
    
    %% Forward Kinematics Detail
    subgraph "Vectorized Forward Kinematics + Collision Checking"
        FK_INPUT["8 Joint Configurations<br/>(SOA format)"]
        FK_INPUT --> FK_COMPUTE["Vectorized Forward Kinematics<br/>Compute all link poses<br/>simultaneously"]
        
        FK_COMPUTE --> SPHERE_POS["8 Sphere Positions<br/>per collision sphere"]
        SPHERE_POS --> COLLISION_ENV["Environment Collision Check<br/>Spheres vs Obstacles"]
        
        subgraph "Environment Types"
            COLLISION_ENV --> SPHERE_COLL["Sphere-Sphere<br/>(vectorized distance)"]
            COLLISION_ENV --> CUBOID_COLL["Sphere-Cuboid<br/>(vectorized containment)"]
            COLLISION_ENV --> CAPSULE_COLL["Sphere-Capsule<br/>(vectorized distance)"]
            COLLISION_ENV --> CLOUD_COLL["Sphere-Pointcloud<br/>(CAPT algorithm)"]
        end
        
        SPHERE_COLL --> FINAL_RESULT["8 Collision Results<br/>(boolean vector)"]
        CUBOID_COLL --> FINAL_RESULT
        CAPSULE_COLL --> FINAL_RESULT
        CLOUD_COLL --> FINAL_RESULT
    end
    
    %% Performance Characteristics
    subgraph "Performance Optimizations"
        PERF_FEATURES["Performance Features:<br/>• Function-local static buffer pools<br/>• Zero-allocation hot paths<br/>• SIMD-aligned memory<br/>• Cache-optimized access<br/>• Compile-time vectorization<br/>• Lazy environment creation"]
        
        PERF_METRICS["Typical Performance:<br/>• 8x collision detection speedup<br/>• ~50% motion planning speedup<br/>• Reduced memory allocations<br/>• Better CPU pipeline utilization"]
    end
    
    %% Robot-specific Configuration
    subgraph "Robot-specific SIMD Parameters"
        ROBOT_PARAMS["Robot Type Parameters:<br/>• dimension: joint count<br/>• n_spheres: collision spheres<br/>• resolution: motion samples<br/>• s_a/s_m: joint limits"]
        
        ROBOT_EXAMPLES["Examples:<br/>• Panda: 7 DOF, 10 spheres, res=64<br/>• UR5: 6 DOF, 8 spheres, res=32<br/>• Fetch: 8 DOF, 12 spheres, res=48"]
    end
    
    %% Style definitions
    classDef traditional fill:#ffebee,stroke:#c62828,stroke-width:2px
    classDef vamp fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef memory fill:#fff3e0,stroke:#ef6c00,stroke-width:2px
    classDef motion fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef forward fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    classDef perf fill:#fff8e1,stroke:#f57f17,stroke-width:2px
    classDef robot fill:#fce4ec,stroke:#c2185b,stroke-width:2px
    
    %% Apply styles
    class T1,T2,T3,T4,TC1,TC2,TC3,TC4,TR1,TR2,TR3,TR4 traditional
    class V1,V2,V3,V4,V5,V6,V7,V8,VL1,VL2,VL3,VL4,VL5,VL6,VL7,VL8,SIMD,VR vamp
    class AOS_START,AOS_MEM,CONV,SOA_MEM,SIMD_OPS memory
    class MOTION_START,RAKE_SAMPLE,INTERP1,INTERP2,INTERP3,INTERP4,INTERP5,INTERP6,INTERP7,INTERP8,LANE1,LANE2,LANE3,LANE4,LANE5,LANE6,LANE7,LANE8,PARALLEL_CHECK,MOTION_RESULT motion
    class FK_INPUT,FK_COMPUTE,SPHERE_POS,COLLISION_ENV,SPHERE_COLL,CUBOID_COLL,CAPSULE_COLL,CLOUD_COLL,FINAL_RESULT forward
    class PERF_FEATURES,PERF_METRICS perf
    class ROBOT_PARAMS,ROBOT_EXAMPLES robot
